package cn.oms.manage.pojo.param;



import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Data
@Accessors
public class CustomerAddNewParam implements Serializable {

    @ApiModelProperty(value = "用户名", required = true)
    @NotNull(message = "添加用户失败，必须提交用户名！")
    private String user;

    @ApiModelProperty(value = "预约电话", required = true)
    @NotNull(message = "添加用户失败，必须提交预约电话！")
    private String phone;

    @ApiModelProperty(value = "预约科室id", required = false)
    private Long departmentId;

    @ApiModelProperty(value = "预约科室名称", required = true)
    @NotNull(message = "添加用户失败，必须提交预约科室名称！")
    private String departmentName;

    @ApiModelProperty(value = "预约时间", required = true)
    @NotNull(message = "添加用户失败，必须提交预约时间！")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime appointment;

    @ApiModelProperty(value = "患病史", required = true)
    @NotNull(message = "添加用户失败，必须提交患病史！")
    private String patient_history;

    @ApiModelProperty(value = "病情描述", required = true)
    @NotNull(message = "添加用户失败，必须提交病情描述！")
    private String description;

    @ApiModelProperty(value = "家庭住址", required = true)
    @NotNull(message = "添加用户失败，必须提交家庭住址！")
    private String address;

    @ApiModelProperty(value = "客户状态", required = true)
    @NotNull(message = "添加用户失败，必须提交客户状态！")
    private String state;

    public void setAppointment(String appointment) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        this.appointment = LocalDateTime.parse(appointment, formatter);
    }
}
